// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import cookie from 'vue-cookie'
import App from '@/App'
import router from '@/router'
import store from '@/store'
import http from '@/utils/http-util'
import * as time from '@/utils/time-util'
import { isAuth, mapTranslate, treeFormat, treeRetrieval, treeForEach, cascaderSuperior } from '@/utils/index'
import cloneDeep from 'lodash/cloneDeep'
import { initThemeColor } from '@/assets/plugins/theme-color-client'
import '@/assets/plugins/element-click.js'
import '@/assets/plugins/element-ui'
import '@/assets/style/index.scss'
import '@/assets/icons'

Vue.config.productionTip = false

// 挂载全局
Vue.prototype.$http = http
Vue.prototype.$time = time
Vue.prototype.$cookie = cookie
Vue.prototype.isAuth = isAuth
Vue.prototype.mapTranslate = mapTranslate
Vue.prototype.treeFormat = treeFormat
Vue.prototype.treeRetrieval = treeRetrieval
Vue.prototype.treeForEach = treeForEach
Vue.prototype.cascaderSuperior = cascaderSuperior

// 初始化系统样式
store.dispatch('system/getSystemInfo').then(res => {
  initThemeColor(res.theme)
})
// 保存整站vuex本地储存初始状态
window.CONFIG['storeState'] = cloneDeep(store.state)

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  // 渲染DOM树方式，然后提供给el进行挂载，否则vue无法渲染视图
  // vue 1.0 版本写法
  // components: { App },
  // vue 2.0 版本写法
  render: createElement => createElement(App),
  template: '<App/>'
})
